IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel.Compat Namespace > EntityManagerAsyncExtensions Class > ExecuteQueryAsync Method : ExecuteQueryAsync(EntityManager,IEntityQuery,Action<EntityQueryOperation>,Object) Method |
'Declaration
<ExtensionAttribute()> Public Overloads Shared Function ExecuteQueryAsync( _ ByVal em As EntityManager, _ ByVal query As IEntityQuery, _ ByVal userCallback As Action(Of EntityQueryOperation), _ Optional ByVal userState As Object _ ) As EntityQueryOperation
'Usage
Dim em As EntityManager Dim query As IEntityQuery Dim userCallback As Action(Of EntityQueryOperation) Dim userState As Object Dim value As EntityQueryOperation value = EntityManagerAsyncExtensions.ExecuteQueryAsync(em, query, userCallback, userState)
[Extension()] public static EntityQueryOperation ExecuteQueryAsync( EntityManager em, IEntityQuery query, Action<EntityQueryOperation> userCallback, object userState )
private void SampleAsynchQuery() { DomainModelEntityManager mgr = new DomainModelEntityManager(); // Build a query and ask mgr to run it asynchronously. var query = mgr.Customers.Where(c => c.CompanyName.StartsWith("C")); int token = 1; mgr.ExecuteQueryAsync(query, AsyncQueryCompleted, token); } void AsyncQueryCompleted(EntityQueryOperation<Customer> e) { if (e.Error != null) { System.Diagnostics.Debug.WriteLine(e.Error.Message); return; } System.Diagnostics.Debug.WriteLine("queryid = " + e.UserState.ToString()); System.Diagnostics.Debug.WriteLine("customers retrieved = " + e.Results.Count().ToString()); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2